home *** CD-ROM | disk | FTP | other *** search
/ Nejlepší hry / Nejlepsi hry.iso / hry / plane arcade / planearcade.exe / tank3.bmp / spitfire.cpp < prev    next >
C/C++ Source or Header  |  2004-09-28  |  24KB  |  968 lines

  1.  
  2. #include "main.h"
  3.  
  4. //-------------
  5. //Global
  6. //-------------
  7. SPITFIRE SpitFire;
  8.  
  9. //Inicializacia
  10. //----------------------------------------------------------
  11. void SPITFIRE::Initialize()
  12. {
  13.  
  14.     //normal model
  15.     //------------
  16.     ModelNormal1.Specular = true;
  17.     ModelNormal1.Normals = false;
  18.     ModelNormal1.SmoothShading = false;
  19.     ModelNormal1.SmoothShading = false;
  20.     ModelNormal1.MultiTexture = true;
  21.     //ModelNormal1.InitializeAse(1,"models/messerschmitt/messerschmitt.ase");
  22.     //ModelNormal1.LoadAse(0,"models/messerschmitt/messerschmitt.ase");
  23.     //ModelNormal1.LoadTexture("models/messerschmitt/messernormal.bmp",GetColor(1.0f,0.0f,1.0f));
  24.     ModelNormal1.InitializeAse(1,"models/spitfire/spitfire.ase");
  25.     ModelNormal1.LoadAse(0,"models/spitfire/spitfire.ase");
  26.     ModelNormal1.LoadTexture("models/spitfire/spitfirenormal1.bmp",GetColor(0.0f,1.0f,0.0f));
  27.     ModelNormal1.LoadEnviroMap("models/spitfire/enviro.bmp");
  28.     ModelNormal1.Sca = F_Scale;
  29.     ModelNormal1.SetMaterial(GetMaterial(GetColor(0.7f,0.7f,0.7f),
  30.                                         GetColor(1.0f,1.0f,1.0f),
  31.                                         GetColor(0.5f,0.5f,0.5f),
  32.                                         GetColor(0.2f,0.2f,0.2f),4.5f));
  33.  
  34.     ModelNormal2.Specular = true;
  35.     ModelNormal2.Normals = false;
  36.     ModelNormal2.SmoothShading = false;
  37.     ModelNormal2.SmoothShading = false;
  38.     ModelNormal2.MultiTexture = true;
  39.     ModelNormal2.InitializeAse(1,"models/spitfire/spitfire.ase");
  40.     ModelNormal2.LoadAse(0,"models/spitfire/spitfire.ase");
  41.     ModelNormal2.LoadTexture("models/spitfire/spitfirenormal2.bmp",GetColor(0.0f,1.0f,0.0f));
  42.     ModelNormal2.LoadEnviroMap("models/spitfire/enviro.bmp");
  43.     ModelNormal2.Sca = F_Scale;
  44.     ModelNormal2.SetMaterial(GetMaterial(GetColor(0.7f,0.7f,0.7f),
  45.                                         GetColor(1.0f,1.0f,1.0f),
  46.                                         GetColor(0.5f,0.5f,0.5f),
  47.                                         GetColor(0.2f,0.2f,0.2f),4.5f));
  48.  
  49.     //destroy model
  50.     //-------------
  51.     ModelDestroyed.Specular = true;
  52.     ModelDestroyed.Normals = false;
  53.     ModelDestroyed.SmoothShading = false;
  54.     ModelDestroyed.InitializeAse(1,"models/spitfire/spitfire.ase");
  55.     ModelDestroyed.LoadAse(0,"models/spitfire/spitfire.ase");
  56.     ModelDestroyed.LoadTexture("models/spitfire/spitfiredestroy.bmp",GetColor(0.0f,1.0f,0.0f));
  57.     ModelDestroyed.Sca = F_Scale;
  58.     ModelDestroyed.SetMaterial(GetMaterial(GetColor(0.3f,0.3f,0.3f),
  59.                                            GetColor(1.0f,1.0f,1.0f),
  60.                                            GetColor(0.5f,0.5f,0.5f),
  61.                                            GetColor(0.2f,0.2f,0.2f),5.0f));
  62.  
  63.  
  64.     //model pre vrhanie stencil tienov
  65.     //---------------------------------
  66.     ModelShadow.OnlyShadow = true;
  67.     ModelShadow.Normals = false;
  68.     ModelShadow.SmoothShading = false;
  69.     ModelShadow.InitializeAse(1,"models/spitfire/spitfireshadow.ase");
  70.     ModelShadow.LoadAse(0,"models/spitfire/spitfireshadow.ase");
  71.     ModelShadow.Sca = F_Scale;
  72.  
  73.     //model vrtuly
  74.     //---------------------------------
  75.     ModelVrtula.Specular = true;
  76.     ModelVrtula.Normals = false;
  77.     ModelVrtula.SmoothShading = false;
  78.     ModelVrtula.Lighting = false;
  79.     ModelVrtula.Color = GetColor(0.3f,0.6f,0.6f,0.6f);
  80.     ModelVrtula.InitializeAse(1,"models/vrtula/vrtula.ase");
  81.     ModelVrtula.LoadAse(0,"models/vrtula/vrtula.ase");
  82.     ModelVrtula.LoadTexture("models/vrtula/vrtula.bmp",GetColor(1.0f,0.0f,1.0f));
  83.     ModelVrtula.Sca = Get3D(1.05f,1.05f,1.05f);
  84.     ModelVrtula.SetMaterial(GetMaterial(GetColor(0.3f,0.3f,0.3f),
  85.                                            GetColor(1.0f,1.0f,1.0f),
  86.                                            GetColor(0.5f,0.5f,0.5f),
  87.                                            GetColor(0.2f,0.2f,0.2f),5.0f));
  88.  
  89.     //model kabina
  90.     //---------------------------------
  91.     ModelKabina.Normals = false;
  92.     ModelKabina.SmoothShading = false;
  93.     ModelKabina.Lighting = false;
  94.     ModelKabina.Color = GetColor(0.5f,1.0f,1.0f,1.0f);
  95.     ModelKabina.InitializeAse(1,"models/spitfire/Kabina.ase");
  96.     ModelKabina.LoadAse(0,"models/spitfire/Kabina.ase");
  97.     ModelKabina.LoadTexture("models/spitfire/Kabina.bmp",GetColor(1.0f,0.0f,1.0f));
  98.     ModelKabina.Sca = F_Scale;
  99.     
  100.     //gulky
  101.     //--------------
  102.     Bullet.Initialize();
  103.     Bullet.Friendly = true;
  104.  
  105.     //bomby
  106.     //----------------
  107.     Bomb.Initialize();
  108.     Bomb.Friendly = true;
  109.  
  110.     BulletFire.Initialize(5,1);
  111.     BulletFire.AddFrame(0,"particles/fire.bmp",GetColor(1.0f,0.0f,0.0f,0.0f));
  112.  
  113.     BulletAlpha = 0.0f;
  114.     Bullet1Rot = 0.0f;
  115.     Bullet2Rot = 0.0f;
  116.  
  117.     //Screens
  118.     //-----------------
  119.     BackGround.Create((float)Engine.Width+10 ,(float)Engine.Height+10,1);
  120.     BackGround.AddFrame("menu/background.bmp",GetColor(1,0,1,0));
  121.  
  122.     MsgBack.Create(512,64,1);
  123.     MsgBack.AddFrame("menu/gui/msgback.bmp",GetColor(0,1,0,1));
  124.  
  125.     Font.Create(30,FW_BOLD,"Arial");    
  126.     MFont.Create(18,FW_BOLD,"Arial");
  127.  
  128.     //zvuk
  129.     //-------------
  130.     Sound.InitialiseForWavMidi();
  131.     Sound.LoadSound("sounds/spitfire.wav");
  132.  
  133.     ShowCompas = true;
  134.     ShowFPS = false;
  135.     ShowMap = true;
  136.     ShowKokpit = false;
  137.     
  138.     //reset hodnot
  139.     //------------
  140.     Reset();
  141.  
  142. }
  143.  
  144. //reset hodnot - na konci kazdej hry
  145. //----------------------------------------------------------
  146. void SPITFIRE::Reset()
  147. {
  148.  
  149.     Life = 100;
  150.     Speed = (SpitFire_MaxSpeed+SpitFire_MinSpeed)/2.0f;
  151.     Score = 0;
  152.     Bombs = 0;
  153.     FakeScore = 0;
  154.     ModelMode = 0;
  155.  
  156.     BulletActive = true;
  157.  
  158.     SoundPlay = false;
  159.     
  160.     BkTime = 1.0f;
  161.     InMode = true;
  162.     OutMode = false;
  163.     ComMode = false;
  164.     FaiMode = false;
  165.     ScoMode = false;
  166.  
  167.     MessageLifeTime = 0.0f;
  168.     MessageOnTime = -1.0f;
  169.     strcpy(MessageBuffer,"");
  170.     
  171.     Bullet.Reset();
  172.     BulletTime = 0.0f;
  173.  
  174.     Bomb.Reset();
  175.     BombTime = 0.0f;
  176.  
  177.     NormalMode = true;
  178.     CrazyMode = false;
  179.     DestroyedMode = true;
  180.  
  181.     Pos = Get3D(0.0f,550.0f,0.0f);;
  182.     Rot = Get3D(0.0f,0.0f,0.0f);
  183.     ConRot = Get3D(0.0f,0.0f,0.0f);
  184.     Matrix = GetMatrix(Pos,Rot,F_Scale);
  185.  
  186.     VrtulaRotation = 0.0f;
  187. }
  188. // StopSound - zastavi zvuk
  189. //--------------------------------------------------------------
  190. void SPITFIRE::StopSound()
  191. {
  192.     SoundPlay = false;
  193.     Sound.Stop();
  194. }
  195.  
  196. //Refresh
  197. //--------------------------------------------------------------
  198. void SPITFIRE::Refresh()
  199. {
  200.     //---------
  201.     //Ovladanie
  202.     //---------
  203.     if (NormalMode == true && Menu.EnabledBriefring == false)
  204.     {
  205.  
  206.         //mys - lietadlo
  207.         float MouseStepX; 
  208.         float MouseStepY;
  209.         MouseStepX = Input.MouseRelative.X;
  210.         MouseStepY = Input.MouseRelative.Y;
  211.     
  212.         //if (MouseStepY >  120.0f) MouseStepY =  120.0f;
  213.         //if (MouseStepY < -120.0f) MouseStepY = -120.0f;
  214.  
  215.         //if (MouseStepX >  120.0f) MouseStepX =  120.0f;
  216.         //if (MouseStepX < -120.0f) MouseStepX = -120.0f;
  217.         
  218.         ConRot.Z -= MouseStepX / ((1000.0f*((10-MouseX)/10.0f))+200.0f);
  219.     
  220.         //obmedzenie vysky
  221.         if (Pos.Y > F_MapHeight)
  222.             ConRot.X += Power(0.04f);
  223.         else
  224.             ConRot.X -= MouseStepY / ((2000.0f*((10-MouseY)/10.0f))+200.0f);
  225.  
  226.         //obmedzenie
  227.         if (ConRot.X > 1.2f)
  228.             ConRot.X = 1.2f;
  229.         if (ConRot.X < -1.2f)
  230.             ConRot.X = -1.2f;
  231.         if (ConRot.Z > 1.4f)
  232.             ConRot.Z = 1.4f;
  233.         if (ConRot.Z < -1.4f)
  234.             ConRot.Z = -1.4f;
  235.  
  236.         //Rot.X += (ConRot.X - Rot.X) * Power(0.58f);
  237.         //Rot.Z += (ConRot.Z - Rot.Z) * Power(0.58f);
  238.  
  239.         Rot.X = ConRot.X;
  240.         Rot.Z = ConRot.Z;
  241.  
  242.         //y natocenie
  243.         Rot.Y -= Power(sinf(Rot.Z)*0.05f);
  244.  
  245.         //strelba
  246.         BulletTime += PowerTime(1.0f);
  247.         if (BulletAlpha>0.0f) BulletAlpha -= Power(0.15f);
  248.         
  249.         if((Input.MouseLeftDown == true )&&(BulletTime > SpitFire_BulletFreq) && BulletActive)
  250.         {
  251.             //vyousti bullet
  252.             Bullet.SpawnBullet(BL,Rot);
  253.             Bullet.SpawnBullet(BR,Rot);
  254.             Explo.SpawnBullet(BL);
  255.             Explo.SpawnBullet(BR);
  256.             BulletTime = 0.0f;
  257.  
  258.             BulletAlpha = 0.75f;
  259.             Bullet1Rot = RandomMinMax(-1.57f,1.57f);
  260.             Bullet2Rot = RandomMinMax(-1.57f,1.57f);
  261.  
  262.             //zvuk
  263.             SoundLib.FireFriendly.SetPosition(Pos,FireFriendly_Scale);
  264.             SoundLib.FireFriendly.Play();
  265.         }
  266.  
  267.         //bomby
  268.         BombTime += PowerTime(1.0f);
  269.         if ((Input.MouseRightDown == true)&&
  270.             (BombTime > SpitFire_BombFreq)&&(Bombs > 0))    
  271.         {
  272.             Bomb.SpawnBomb(SpitFire.Pos,SpitFire.Rot,SpitFire.Speed);
  273.             BombTime = 0.0f;
  274.             Bombs--;
  275.         }
  276.  
  277.         //rychlost
  278.         if (Input.KeyDOWN[DIK_RSHIFT] == true ||
  279.             Input.KeyDOWN[DIK_LSHIFT] == true)
  280.         {
  281.             if (Speed < SpitFire_MaxSpeed)
  282.                 Speed += Power(0.1f);
  283.  
  284.         }
  285.         if (Input.KeyDOWN[DIK_RCONTROL] == true ||
  286.             Input.KeyDOWN[DIK_LCONTROL] == true)
  287.         {
  288.             if (Speed > SpitFire_MinSpeed)
  289.                 Speed -= Power(0.1f);
  290.         }
  291.  
  292.         //Kompas
  293.         if (Input.KeyPRESS[DIK_K] == true)
  294.         {
  295.             ShowCompas = !ShowCompas ;
  296.         }
  297.         //Mapa
  298.         if (Input.KeyPRESS[DIK_M] == true)
  299.         {
  300.             ShowMap = !ShowMap; 
  301.         }
  302.         //FPS
  303.         if (Input.KeyPRESS[DIK_F] == true)
  304.         {
  305.             ShowFPS = !ShowFPS; 
  306.         }
  307.         //Kokpit
  308.         if (Input.KeyPRESS[DIK_C] == true)
  309.         {
  310.             ShowKokpit = !ShowKokpit ;
  311.         }
  312.     }
  313.  
  314.     //briefring
  315.     if (Input.KeyPRESS[DIK_ESCAPE] == true)
  316.     {
  317.         //spusti briefring
  318.         Menu.EnabledBriefring = true;
  319.     }
  320.  
  321.     //-------------------------------------
  322.     //vypocitanie matice podla ktorej sa posunie
  323.     //------------------------------------
  324.     Matrix = GetMatrix(Pos,Rot,F_Scale);
  325.  
  326.     //-------------
  327.     //Sledovaci bod
  328.     //-------------
  329.     SlPoint = TransformPoint(Get3D(0.0f,0.0f,80.0f),
  330.                               Matrix);
  331.  
  332.     //---------
  333.     //posunutie
  334.     //---------
  335.     if (NormalMode || CrazyMode)
  336.     {
  337.  
  338.         //posun
  339.         Pos = TransformPoint(Get3D(0.0f,0.0f,Power(Speed)),
  340.                               Matrix);
  341.     }
  342.  
  343.     //-------------------------------------
  344.     //vypocitanie matice a koliznych bodov
  345.     //------------------------------------
  346.     Matrix = GetMatrix(Pos,Rot,F_Scale);
  347.  
  348.     //kolizne body
  349.     PL = SpitFire_Left;
  350.     PR = SpitFire_Right;
  351.     PU = SpitFire_Up;
  352.     PD = SpitFire_Down;
  353.     PF = SpitFire_Front;
  354.     PB = SpitFire_Back;
  355.  
  356.     PL = TransformPoint(PL,Matrix);
  357.     PR = TransformPoint(PR,Matrix);
  358.     PB = TransformPoint(PB,Matrix);
  359.     PF = TransformPoint(PF,Matrix);
  360.     PU = TransformPoint(PU,Matrix);
  361.     PD = TransformPoint(PD,Matrix);
  362.  
  363.     //gulomety
  364.     BL = TransformPoint(SpitFire_BulletLeft,Matrix);
  365.     BR = TransformPoint(SpitFire_BulletRight,Matrix);
  366.  
  367.     //vrtula
  368.     PV = TransformPoint(SpitFire_VrtulaPoint,Matrix);
  369.  
  370.     //----------------
  371.     //camera
  372.     //----------------
  373.     SetCamera();
  374.  
  375.     //-------------
  376.     //Zvuk motora
  377.     //-------------
  378.     if (NormalMode || CrazyMode)
  379.     {
  380.         Sound.SetPosition(Pos,SpitFire_SoundScale);
  381.         if (SoundPlay == false && Menu.EnabledBriefring == false)
  382.         {
  383.             SoundPlay = true;
  384.             Sound.Play(true);    
  385.         }
  386.     }
  387.  
  388.     //----------------
  389.     //kolizie
  390.     //----------------
  391.     bool GroundCollision = GetGroundCollision();
  392.  
  393.     //-------------
  394.     //process
  395.     //-------------
  396.     if (NormalMode)
  397.     {
  398.         
  399.         //kolizia zo zemov
  400.         if (GroundCollision == true)
  401.         {
  402.  
  403.             //particle
  404.             Explo.SpawnExplosion(Pos);
  405.             Explo.SpawnParticle(Pos);
  406.  
  407.             DestroyedMode = true;
  408.             NormalMode = false;
  409.             Life = -2;
  410.  
  411.             //zvuk
  412.             SoundLib.ExplodeLarge.SetPosition(Pos,ExplodeLarge_Scale);
  413.             SoundLib.ExplodeLarge.Play();
  414.         }
  415.  
  416.         //zivoty
  417.         if (Life <= 0)
  418.         {
  419.             //particle
  420.             Explo.SpawnExplosion(Pos);
  421.             Explo.SpawnParticle(Pos);
  422.  
  423.             CrazyMode = true;
  424.             NormalMode = false;
  425.  
  426.             //zvuk
  427.             SoundLib.ExplodeSmall.SetPosition(Pos,ExplodeSmall_Scale);
  428.             SoundLib.ExplodeSmall.Play();
  429.         }
  430.  
  431.         
  432.     }
  433.     else if(CrazyMode)
  434.     {
  435.  
  436.         //kolizia zo zemov
  437.         if (GroundCollision == true)
  438.         {
  439.             //particle
  440.             Explo.SpawnExplosion(Pos);
  441.             Explo.SpawnParticle(Pos);
  442.  
  443.             DestroyedMode = true;
  444.             CrazyMode = false;
  445.  
  446.             //zvuk
  447.             SoundLib.ExplodeLarge.SetPosition(Pos,ExplodeLarge_Scale);
  448.             SoundLib.ExplodeLarge.Play();
  449.         }
  450.  
  451.         //crazy
  452.         Rot.Z += Power(0.1f);
  453.         Rot.X += Power(0.005f);
  454.         Pos.Y -= Power(2.0f);
  455.  
  456.         //particle
  457.         Explo.SpawnSmokePlane(Pos);
  458.         Explo.SpawnSmokeHit(Pos);
  459.  
  460.     }
  461.     else if(DestroyedMode)
  462.     {
  463.         MissionFailed();    
  464.  
  465.         Explo.SpawnSmokeGround(Pos);
  466.     }
  467.      
  468.  
  469.  
  470. }
  471.  
  472. //misia kompletna
  473. //--------------------------------------------------------
  474. void SPITFIRE::MissionCompleted()
  475. {
  476.     //zapise novy array
  477.     if (ComMode == false && FaiMode == false && OutMode == false)
  478.     {
  479.         Menu.SaveArray(Level.LevelIndex+1);
  480.     }
  481.  
  482.     OutMode = true;
  483.     ComMode = true;
  484. }
  485.  
  486. //misia kompletna
  487. //--------------------------------------------------------
  488. void SPITFIRE::MissionExit()
  489. {
  490.     OutMode = true;
  491.     FaiMode = false;
  492. }
  493.  
  494. //misia failed
  495. //--------------------------------------------------------
  496. void SPITFIRE::MissionFailed()
  497. {
  498.     if (Level.LevelIndex > 0)
  499.     {
  500.         if (OutMode == false) FaiMode = true;
  501.         OutMode = true;
  502.     }
  503.     if (Level.LevelIndex == 0)
  504.     {
  505.         ScoMode = true;
  506.     }
  507. }
  508.  
  509. //vyrenderuje oznamy pre hraca alebo obrazovky
  510. //--------------------------------------------------------
  511. void SPITFIRE::DrawScreens()
  512. {
  513.  
  514.     //naliehava sprava
  515.     if (Level.StageTime < MessageOnTime + MessageLifeTime)
  516.     {
  517.         
  518.         if (MsgBack.Color.A < 1.0f) MsgBack.Color.A += Power(0.05f);
  519.         MsgBack.Pos = Get3D(Engine.Width/2.0f,Engine.Height-130.0f,0.0f);
  520.         
  521.         Engine.SetBlendTrans();
  522.             MsgBack.Render();
  523.         Engine.SetBlendNone();
  524.  
  525.         if (MsgBack.Color.A > 0.3f && MsgBack.Color.A < 0.4f)
  526.             MFont.Print(Engine.Width/2-215,Engine.Height - 137,GetColor(0.0f,0.0f,0.0f),"M");
  527.         if (MsgBack.Color.A > 0.4f && MsgBack.Color.A < 0.5f)
  528.             MFont.Print(Engine.Width/2-215,Engine.Height - 137,GetColor(0.0f,0.0f,0.0f),"Me");
  529.         if (MsgBack.Color.A > 0.5f && MsgBack.Color.A < 0.6f)
  530.             MFont.Print(Engine.Width/2-215,Engine.Height - 137,GetColor(0.0f,0.0f,0.0f),"Mes");
  531.         if (MsgBack.Color.A > 0.6f && MsgBack.Color.A < 0.7f)
  532.             MFont.Print(Engine.Width/2-215,Engine.Height - 137,GetColor(0.0f,0.0f,0.0f),"Mess");
  533.         if (MsgBack.Color.A > 0.7f && MsgBack.Color.A < 0.8f)
  534.             MFont.Print(Engine.Width/2-215,Engine.Height - 137,GetColor(0.0f,0.0f,0.0f),"Messa");
  535.         if (MsgBack.Color.A > 0.8f && MsgBack.Color.A < 0.9f)
  536.             MFont.Print(Engine.Width/2-215,Engine.Height - 137,GetColor(0.0f,0.0f,0.0f),"Messag");
  537.         if (MsgBack.Color.A > 0.9f && MsgBack.Color.A < 2.0f)
  538.             MFont.Print(Engine.Width/2-215,Engine.Height - 137,GetColor(0.0f,0.0f,0.0f),"Message:");
  539.  
  540.         if (MsgBack.Color.A > 1.0f)
  541.             MFont.Print(Engine.Width/2-140,Engine.Height - 137,GetColor(0.0f,0.0f,0.0f),MessageBuffer);
  542.         
  543.     }
  544.     else
  545.     {
  546.         if (MsgBack.Color.A > 0.0f) MsgBack.Color.A -= Power(0.05f);
  547.         MsgBack.Pos = Get3D(Engine.Width/2.0f,Engine.Height - 130.0f,0.0f);
  548.     
  549.         Engine.SetBlendTrans();
  550.             MsgBack.Render();
  551.         Engine.SetBlendNone();
  552.  
  553.         MessageOnTime = -1.0f;
  554.         MessageLifeTime = 0.0f;
  555.     }
  556.  
  557.     //backtobattle
  558.     if ((Pos.X < -SpitFire_MapSize || Pos.X > SpitFire_MapSize) ||
  559.         (Pos.Y < -SpitFire_MapSize || Pos.Y > SpitFire_MapSize) ||
  560.         (Pos.Z < -SpitFire_MapSize || Pos.Z > SpitFire_MapSize))
  561.     {
  562.  
  563.         if (((Pos.X < -F_MapSize || Pos.X > F_MapSize) ||
  564.         (Pos.Y < -F_MapSize || Pos.Y > F_MapSize) ||
  565.         (Pos.Z < -F_MapSize || Pos.Z > F_MapSize)))
  566.         {
  567.             MissionFailed();    
  568.         }
  569.         else
  570.         {
  571.             if (!FaiMode && !ComMode && !ScoMode)
  572.             {
  573.                 if (Language == 0)
  574.                 Font.Print((int)(Engine.Width/2.0f-230.0f),(int)(Engine.Height/2.0f+75),
  575.                        GetColor(1.0f,1.0f,0.0f),"YOU MUSS FLIGHT BACK INTO BATTLE");
  576.                 if (Language == 1)
  577.                 Font.Print((int)(Engine.Width/2.0f-180.0f),(int)(Engine.Height/2.0f+75),
  578.                         GetColor(1.0f,1.0f,0.0f),"MUSIS LETET SPET DO BOJE");
  579.             }
  580.         }
  581.     }
  582.     
  583.     //font
  584.     if (FaiMode) //misia neuspesna
  585.     {
  586.         if (Language == 0)
  587.         Font.PrintCenter(0,(int)(Engine.Height/2.0f+75),
  588.                    GetColor(1.0f,0.0f,0.0f),"MISSION FAILED");
  589.     
  590.         if (Language == 1)
  591.         Font.PrintCenter(0,(int)(Engine.Height/2.0f+75),
  592.                    GetColor(1.0f,0.0f,0.0f),"MISE NE┌SP╠èN┴");
  593.  
  594.         if (ComMode) ComMode = false;
  595.         if (ScoMode) ScoMode = false;
  596.     }
  597.     if (ComMode) //misia uspesna
  598.     {
  599.         if (Language == 0)
  600.         Font.PrintCenter(0,(int)(Engine.Height/2.0f+75),
  601.                    GetColor(0.0f,1.0f,0.0f),"MISSION COMPLETED");
  602.  
  603.         if (Language == 1)
  604.         Font.PrintCenter(0,(int)(Engine.Height/2.0f+75),
  605.                    GetColor(0.0f,1.0f,0.0f),"MISE ┌SP╠èN┴");
  606.     }
  607.     if (ScoMode) //tvoje score
  608.     {
  609.         char cBuf[80];
  610.         if (Language == 0) sprintf(cBuf,"YOUR SCORE: %d",SpitFire.Score);
  611.         if (Language == 1) sprintf(cBuf,"TVOJE SCORE: %d",SpitFire.Score);
  612.         Font.PrintCenter(0,(int)(Engine.Height/2.0f+75),
  613.                    GetColor(1.0f,1.0f,0.0f),cBuf);
  614.     }
  615.  
  616.     
  617.     //background
  618.     if (InMode)
  619.     {
  620.         BkTime -= Power(0.02f);
  621.         if (BkTime < 0.0f)
  622.         {
  623.             InMode = false;
  624.             Menu.EnabledBriefring = true;
  625.         }
  626.     }
  627.     if (OutMode)
  628.     {
  629.         BkTime += Power(0.015f);
  630.         if(BkTime > 1.0f)
  631.         {
  632.             Menu.EnabledMenu = true;
  633.             Level.StopAllSounds();
  634.  
  635.             if(FaiMode)
  636.             {
  637.                 Level.StartGame(Level.LevelIndex);
  638.                 //aby spitfire nestrielal
  639.                 SpitFire.BulletTime = -400.0f;
  640.                 Menu.EnabledMenu = false;
  641.             }
  642.         }
  643.     }
  644.  
  645.     if (InMode || OutMode)
  646.     {    
  647.         Engine.SetBlendTrans();
  648.             BackGround.Center(Get3D(0.5f,0.5f,0.0f));
  649.             BackGround.Color = GetColor(BkTime,1.0f,1.0f,1.0f);
  650.             BackGround.Render();
  651.         Engine.SetBlendNone();
  652.     }
  653.  
  654. }
  655.  
  656. //vyrenderuje + tien lietadla
  657. //--------------------------------------------------------
  658. void SPITFIRE::Render()
  659. {
  660.  
  661.     //----------
  662.     //Render
  663.     //-----------
  664.  
  665.     //stencil svetlo
  666.     StencilShadow.LightPosition.X = Pos.X + 200.0f;
  667.     StencilShadow.LightPosition.Y = Pos.Y + 4000.0f;
  668.     StencilShadow.LightPosition.Z = Pos.Z + 200.0f;
  669.     
  670.     //Naboje
  671.     Bullet.Refresh();
  672.  
  673.     //bomby
  674.     Bomb.Refresh();
  675.  
  676.     //Normal
  677.     if ((NormalMode)||(CrazyMode))
  678.     {
  679.  
  680.         //shadow
  681.         if (Shadows == 1)
  682.         {
  683.             ModelShadow.Pos = Pos;
  684.             ModelShadow.Rot = Rot;
  685.             ModelShadow.Render();
  686.             ModelShadow.BuildShadow(&StencilShadow);
  687.         }
  688.  
  689.         //aircraft
  690.         if (ModelMode == 1)
  691.         {
  692.             ModelNormal1.Pos = Pos;
  693.             ModelNormal1.Rot = Rot;
  694.             ModelNormal1.Render();
  695.         }
  696.         if (ModelMode == 2)
  697.         {
  698.             ModelNormal2.Pos = Pos;
  699.             ModelNormal2.Rot = Rot;
  700.             ModelNormal2.Render();
  701.         }
  702.         if (ModelMode == 3)
  703.         {
  704.             ModelLib.MesserSchmitt_ModelNormal.Pos = Pos;
  705.             ModelLib.MesserSchmitt_ModelNormal.Rot = Rot;
  706.             ModelLib.MesserSchmitt_ModelNormal.Render();
  707.         }
  708.  
  709.         //kabina
  710.         if (ModelMode == 1 || ModelMode == 2)
  711.         {
  712.             Engine.SetBlendTrans();
  713.                 ModelKabina.Rot = Rot;
  714.                 ModelKabina.Pos = Pos;
  715.                 ModelKabina.Render();
  716.             Engine.SetBlendNone();
  717.         }
  718.  
  719.         //vrtula
  720.         VrtulaRotation += Power((Speed-5.0f)/15.0f);
  721.  
  722.         ModelVrtula.Pos = PV;
  723.         ModelVrtula.Rot = Rot;
  724.  
  725.         Engine.SetBlendTrans();
  726.         Engine.SetAlphaTest(true);
  727.             ModelVrtula.Rot.Z = VrtulaRotation;
  728.             ModelVrtula.Render();
  729.         Engine.SetBlendNone();
  730.  
  731.         //render bullet fire
  732.         Engine.SetBlendCustom(D3DBLEND_SRCCOLOR,D3DBLEND_ONE);
  733.             BulletFire.RenderParticle(BL,
  734.                                       GetColor(BulletAlpha,BulletAlpha,BulletAlpha,BulletAlpha),
  735.                                       5.0f,
  736.                                       Bullet1Rot,
  737.                                       0.0f);
  738.             BulletFire.RenderParticle(BR,
  739.                                       GetColor(BulletAlpha,BulletAlpha,BulletAlpha,BulletAlpha),
  740.                                       5.0f,
  741.                                       Bullet2Rot,
  742.                                       0.0f);
  743.             BulletFire.Render();
  744.         Engine.SetBlendNone();
  745.         
  746.     }
  747.     //destroyed
  748.     else if(DestroyedMode)
  749.     {
  750.         if (Shadows == 1)
  751.         {
  752.             ModelShadow.Pos = Pos;
  753.             ModelShadow.Rot = Rot;
  754.             ModelShadow.Render();
  755.             ModelShadow.BuildShadow(&StencilShadow);
  756.         }
  757.  
  758.         ModelDestroyed.Pos = Pos;
  759.         ModelDestroyed.Rot = Rot;
  760.         ModelDestroyed.Render();
  761.     }
  762.  
  763. }
  764.  
  765.  
  766. //camera
  767. //-------------------------------------------------------
  768. void SPITFIRE::SetCamera()
  769. {
  770.  
  771.     //-------------
  772.     //Camera
  773.     //-------------
  774.     D3DXMATRIX CamMat = GetMatrix(Pos,Rot,F_Scale);
  775.  
  776.     if (NormalMode )
  777.     {
  778.  
  779.         if ((ShowKokpit || Input.KeyDOWN[DIK_DOWN] == true || Input.KeyDOWN[DIK_S] == true) && 
  780.              ModelMode != 3)
  781.         {
  782.             Camera.Pos = TransformPoint(Get3D(0.0f,12.0f,-9.0f),CamMat);
  783.             Camera.Rot.X = -SpitFire.Rot.X;    
  784.             Camera.Rot.Z =  SpitFire.Rot.Z;    
  785.             Camera.Rot.Y =  SpitFire.Rot.Y;
  786.             Camera.RefreshYawPitchRoll();
  787.         }
  788.         else if (Input.KeyDOWN[DIK_UP] == true || Input.KeyDOWN[DIK_W] == true)
  789.         {
  790.             Camera.ActPos = TransformPoint(Get3D(0.0f,0.0f,320.0f),CamMat);    
  791.             Camera.Lok = Pos;
  792.             Camera.RefreshLookAt();
  793.         }
  794.         else if (Input.KeyDOWN[DIK_LEFT] == true || Input.KeyDOWN[DIK_A] == true)
  795.         {
  796.             Camera.ActPos = TransformPoint(Get3D(-150.0f,60.0f,100.0f),CamMat);    
  797.             Camera.Lok = Pos;
  798.             Camera.RefreshLookAt();
  799.         }
  800.         else if (Input.KeyDOWN[DIK_RIGHT] == true || Input.KeyDOWN[DIK_D] == true)
  801.         {
  802.             Camera.ActPos = TransformPoint(Get3D(150.0f,60.0f,100.0f),CamMat);    
  803.             Camera.Lok = Pos;
  804.             Camera.RefreshLookAt();
  805.         }
  806.         else if (Input.KeyDOWN[DIK_NUMPAD0] == true)
  807.         {
  808.             Camera.ActPos = Get3D(0.0f,360.0f,0.0f);
  809.             Camera.Lok = Pos;
  810.             Camera.RefreshLookAt();
  811.         }
  812.         else
  813.         {
  814.             Camera.ActPos = TransformPoint(Get3D(0.0f,41.0f,-50.0f),CamMat);    
  815.             Camera.Lok = Pos;
  816.             Camera.RefreshLookAt();
  817.         }
  818.     }
  819.     else if(CrazyMode)
  820.     {
  821.         Camera.ActPos = TransformPoint(Get3D(0.0f,0.0f,-160.0f),CamMat);
  822.         Camera.ActPos.Y += 60.0f;
  823.         Camera.Lok = Pos;
  824.         Camera.RefreshLookAt();
  825.     }
  826.     else if(DestroyedMode)
  827.     {
  828.         Camera.ActPos.X = Pos.X + 600.0f;
  829.         Camera.ActPos.Z = Pos.Z + 600.0f;
  830.         Camera.ActPos.Y = Pos.Y + 300.0f;
  831.         Camera.Lok = Pos;
  832.         Camera.RefreshLookAt();
  833.     }
  834.     
  835.     
  836.  
  837.  
  838. }
  839.  
  840. //kolizia lietadla zo zemov a objektami
  841. //--------------------------------------------------------
  842. bool SPITFIRE::GetGroundCollision()
  843. {
  844.     int i=0;
  845.  
  846.     //Zem
  847.     //-------------
  848.     if (Level.Krajina.Collise(PD,PU) == true)
  849.     {
  850.         return true;
  851.     }
  852.     if (Level.Krajina.Collise(PB,PF) == true)
  853.     {
  854.         return true;
  855.     }
  856.     if (Level.Krajina.Collise(PR,PL) == true)
  857.     {
  858.         Life = -1; //ked sa cuchne kridol len odober zivot
  859.         return false;
  860.     }
  861.  
  862.  
  863.     //messerschmitt
  864.     //-------------
  865.     for (i=0;i<Max_MesserSchmitt;i++)
  866.     {
  867.         if (Level.MesserSchmitt[i].CollisionDetail(PR,PL) == true)
  868.         {
  869.             //nastav zivoty ale nevrat koliziu 
  870.             //lietadlo zacne padat a neostane vovzduchu
  871.             Life = -1;
  872.             Level.MesserSchmitt[i].Life = -1;
  873.             return false;
  874.         }
  875.     }
  876.  
  877.     //Volker
  878.     //-------------
  879.     for (i=0;i<Max_Volkers;i++)
  880.     {
  881.         if (Level.Volker[i].CollisionDetail(PR,PL) == true)
  882.         {
  883.             //nastav zivoty ale nevrat koliziu 
  884.             //lietadlo zacne padat a neostane vovzduchu
  885.             Life = -1;
  886.             Level.Volker[i].Life = -1;
  887.             return false;
  888.         }
  889.     }
  890.  
  891.     //Bombarder
  892.     //-------------
  893.     for (i=0;i<Max_Bombarders;i++)
  894.     {
  895.         if ( Level.Bombarder[i].CollisionDetail(PR,PL) == true ||
  896.              Level.Bombarder[i].CollisionDetail(PB,PF) == true )
  897.         {
  898.             //nastav zivoty ale nevrat koliziu 
  899.             //lietadlo zacne padat a neostane vovzduchu
  900.             Life = -1;
  901.             return false;
  902.         }
  903.     }
  904.     
  905.  
  906.     //structures
  907.     //-------------
  908.     for (i=0;i<Max_Structures;i++)
  909.     {
  910.         if (Level.Structure[i].CollisionDetail(PR,PL) == true)
  911.         {
  912.                     
  913.             Life = -1;
  914.             return false;
  915.         }
  916.  
  917.         if(    Level.Structure[i].CollisionDetail(PD,PU) == true ||
  918.             Level.Structure[i].CollisionDetail(PB,PF) == true)
  919.         {
  920.             Level.Structure[i].Destroyed = true;
  921.             Level.Structure[i].Normal = false;
  922.             
  923.             Life = -1;
  924.             return true;
  925.         }
  926.     }
  927.  
  928.     //trucks
  929.     //-------------
  930.     for (i=0;i<Max_Trucks;i++)
  931.     {
  932.         if (Level.Truck[i].CollisionDetail(PR,PL) == true )
  933.         {
  934.             Level.Truck[i].DestroyedMode = true;
  935.             Level.Truck[i].NormalMode = false;
  936.             
  937.             Life = -1;
  938.             return true;
  939.         }
  940.     }
  941.         
  942.     return false;
  943.  
  944. }
  945.  
  946. //message - vytlaci spravu o zmene ciela
  947. //-------------------------------------------------------------
  948. void SPITFIRE::DrawMessage(char *MessageEng,char *MessageCze,float LifeTime)
  949. {
  950.     if (Language == 0)    strcpy(MessageBuffer,MessageEng);
  951.     if (Language == 1)    strcpy(MessageBuffer,MessageCze);
  952.     MessageLifeTime = LifeTime;
  953.     MessageOnTime = Level.StageTime;
  954. }
  955.  
  956. //kolizia
  957. //-------------------------------------------------------------
  958. bool SPITFIRE::CollisionBox(VECTOR3D P1, VECTOR3D P2)
  959. {
  960.     return ModelNormal1.CollisionBox(P1,P2,Matrix);
  961. }
  962.  
  963. //kolizia
  964. //-------------------------------------------------------------
  965. bool SPITFIRE::CollisionDetail(VECTOR3D P1, VECTOR3D P2)
  966. {
  967.     return ModelNormal1.CollisionDetail(P1,P2,Matrix);
  968. }